< previous page page_638 next page >

Page 638
Note.gif
The third rule of data normalization states that if a column does not fully describe the index key, that column should be moved to a separate table. In other words, if the columns in your table don't really need to be in this table, they probably need to be somewhere else. Databases that follow this rule are known to be in the Third Normal Form.

In these database examples, you have data describing the various departments in the company stored in the Employees table. Although the DeptID field is important to the Employees description (it describes the department to which the employee belongs), the department-specific data should not be stored with the employee data. Yes, you need another table. This table should contain only department-specific data and be linked to the Employees table through the DeptID field. Table 16.3 lists the modified Employees table and the new Departments table.
Table 16.3. The modified Employees table and the new Departments table.
EmployeesDepartments
EmpIDDeptID
EmpNameDeptName
DeptIDDeptLocation

Notice that the Employees table is much simpler now that you have eliminated all unrelated fields. Use Visdata to construct SQL DDL statements that create the new Departments table and then modify the Employees table and the EmpSkills table to increase database integrity (yes, more foreign keys!). First, use the SQL DDL in Listing 16.4 to create the Departments table. Check your work against Figure 16.5.
Type.gifListing 16.4. Creating the Departments table.
CREATE TABLE Departments
  (DeptID TEXT(5),
   DeptName TEXT(20),
   DeptLocation TEXT(20),
   CONSTRAINT PKDeptID PRIMARY KEY (DeptID))

 
< previous page page_638 next page >

If you like this book, buy it!